package com.wisdom.datebases;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class BaseSqliteDatabase extends SQLiteOpenHelper 
{
	public static final String CITY_LIST = "CITY_LIST";
	
	public BaseSqliteDatabase(Context context,int vision) 
	{
		super(context, "wisdomclient.db", null, vision);
	}

	//数据库创建的时候调用，去创建一张表
	@Override
	public void onCreate(SQLiteDatabase db) 
	{
		db.execSQL("CREATE TABLE CITY_LIST(_id INTEGER PRIMARY KEY AUTOINCREMENT," +
				"CITY_NAME NTEXT,CITY_PROVINCE NTEXT,CITY_PINYIN NTEXT," +
				"CITY_SELECT_COUNT INTEGER)");
		db.execSQL("INSERT INTO CITY_LIST VALUES('长沙','湖南','changsha',0)");
		db.execSQL("INSERT INTO CITY_LIST VALUES('常德','湖南','changde',0)");

	}

	//数据库版本提升的时候调用,比如软件升级时，要在原本的数据库一个表里面新增加一个字段，或者增加一张表，就在这里面修改数据库
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) 
	{
		db.execSQL("DROP CITY_LIST");
		this.onCreate(db);
	}

}
